package org.demo;

import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.ConfigurableApplicationContext;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Optional;

/**
 * @author yexi
 * @see com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper
 * @see DruidStatProperties
 */
@SpringBootApplication
@Slf4j
public class Main {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext run = SpringApplication.run(Main.class, args);
        Integer port = run.getBean(ServerProperties.class).getPort();
        log.info("服务已启动，druid监控地址地址: http://{}:{}/druid", InetAddress.getLocalHost().getHostAddress(), Optional.ofNullable(port).orElse(8080));
    }
}